<link rel="stylesheet" href="{$modules_dir}fichevitrine/css/common.css" type="text/css"/>
<link rel="stylesheet" href="{$modules_dir}fichevitrine/css/add.css" type="text/css"/>

<div class="fichevitrine_module">
	
    <h1>{l s="Mon espace fiche vitrine" mod='fichevitrine'}</h1>
	<table class="vitrinemenu">
		<tr>
			<td><a href="{$linkHome}">{l s="Accueil" mod='fichevitrine'}</a></td>
			<td><a href="{$linkAddModel}"  class="menuSelected">{l s="Créer un modèle" mod='fichevitrine'}</a></td>
			<td><a href="{$linkListModel}">{l s="Accéder à mes modèles" mod='fichevitrine'}</a></td>
			<td><a href="{$linkAddFiche}">{l s="Créer une fiche" mod='fichevitrine'}</a></td>
			<td><a href="{$linkListFiche}">{l s="Accéder à mes fiches" mod='fichevitrine'}</a></td>
			<td><a href="{$linkPrint}">{l s='Imprimer' mod='fichevitrine'}</a></td>
			<td><a href="{$manual}">{l s='Manuel' mod='fichevitrine'}</a></td>
		</tr>
	</table>
    <p>{$message}</p>
	
	{if $totalWeight >= $maxWeight }
		<p>
			{l s="Attention, le poids total de vos fiches est de" mod='fichevitrine'} : <strong>{$totalWeight}Mo</strong>
			{l s="et excède le poids maximum autorisé pour votre compte qui est de" mod='fichevitrine'} : <strong>{$maxWeight}Mo.</strong>
		</p>
		<p>
			{l s="Veuillez éditer ou supprimer certaines fiches afin que celles-ci prennent moins de place, 
			vous pourrez ainsi créer de nouvelles fiches et modèles." mod='fichevitrine'}
		</p>
	{else}
    <form method="post" action="{$linkAdd}" class="filters" onsubmit="return submitHandler();">
        <table class="list">
			<tr>
			<td>
                    <label for="name">{l s="Nom" mod='fichevitrine'} </label>
                    <input type="text" name="name" value="{$defaultName}" />
                	</td>

			<td>
                    <label>{l s="Format-max" mod='fichevitrine'} </label>
                    <select name="format">
                        {foreach from=$formats item=currentF}
                            <option value="{$currentF}" {if $currentF == $defaultFormat}selected="selected"{/if}>
                                {$currentF}
                            </option>
                        {/foreach}
                    </select>
                	</td>   
			<td>
                    <label>{l s="Orientation" mod='fichevitrine'} </label>
                    <select name="orientation">
                        {foreach $orientations as $key=>$value}
                            <option value="{$value}">
                                {$key}
                            </option>
                        {/foreach}
                    </select>
                	</td>    
            </tr>
            <tr>
               <td>
			<label for="transact">{l s="Location/Vente" mod='fichevitrine'}</label>
			<select name="transact" id="transact">
			
			{*	<option value="0">{l s="Vente" mod='fichevitrine'}</option>
				<option value="1">{l s="Location" mod='fichevitrine'}</option>
			*}
			 {foreach $transacts as $key => $value}
				<option value="{$value}">
					{$key}
				</option>
             {/foreach}
			</select>
		</td>

                    <td>
			<label>{l s="Type de bien" mod='fichevitrine'} </label>
                    <select name="propId">
                        <option value="-1">{l s="Aucun" mod='fichevitrine'}</option>
                        {foreach from=$goodTypes key=value item=currentGoodType}
                            <option value="{$currentGoodType->id_prop}">
                                {$currentGoodType->getName()}
                            </option>
                        {/foreach}
                    </select>
               	   </td>
			<td>
				    <label>{l s="Classement thème (optionnel)" mod='fichevitrine'} </label>
				    <select name="theme">
				        <option value="-1">{l s="Aucun" mod='fichevitrine'}</option>
				        {foreach from=$themes key=value item=currentTheme}
				            <option value="{$currentTheme->id_theme}">
				                {$currentTheme->getName()}
				            </option>
				        {/foreach}
				    </select>
				</td>	
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td>
				    <label>{l s="Rendre ce modèle public" mod='fichevitrine'} </label>
				    <input type="checkbox" value="0" name="isPublic" />
			       	 </td>
				
				<td>
					<input type="hidden" name="modelId" id="modelId" value=""/>
					<input type="submit" name="submitAddForm" value="{l s='Créer' mod='fichevitrine'}" />	
				</td>
			</tr>
        </table>
		
	</form>
    <form method="POST" action="{$linkAdd}">
        <h3>{l s="Sélectionner un modèle ou une fiche" mod='fichevitrine'} :</h3>
		<table class="list">
			<tr>
				<td>
					<label for="f_type">{l s="Type" mod='fichevitrine'} </label>
					<select name="f_type">
					<option value="-1">{l s="Tous" mod='fichevitrine'}</option>				
					{*	{foreach from=$types key=value item=label}
							<option value="{$value}" {if $currentType == $value} selected="selected" {/if}>
								{$label}
							</option>
						{/foreach}
					*}
					{foreach $types as $key=>$value}
						<option value="{$value}" {if $currentType == $value} selected="selected"{/if}>
							{$key}
						</option>
					{/foreach}	
					</select>
				</td>

				<td>
					<label for="f_format">{l s="Format" mod='fichevitrine'} </label>
                    <select name="f_format">
                        <option value="-1">{l s="Tous" mod='fichevitrine'}</option>
                        {foreach $formats as $key=>$value}
                            <option value="{$value}" {if $currentFormat == $value} selected="selected"{/if}>
                                {$value}
                            </option>
                        {/foreach}
                    </select>
				</td>
				<td>
					<label for="f_orientation">{l s="Orientation_" mod='fichevitrine'} </label>
                    <select name="f_orientation">
                        <option value="-1">{l s="Tous" mod='fichevitrine'}</option>
                        
                        {foreach $orientations as $key=>$value}
                            <option value="{$value}" {if $currentOrientation == $value} selected="selected"{/if}>
                                {$key}
                            </option>
                        {/foreach}
                     
                    </select>
				</td>
			</tr>
			<tr>
				<td>
					<label for="f_transact">{l s="Location/Vente_" mod='fichevitrine'}</label>
					<select name="f_transact" id="f_transact">
						<option value="-1">{l s="Tous" mod='fichevitrine'}</option>
						
						{*
						<option value="0" {if $currentRent == 0}selected="selected"{/if}>{l s="Vente" mod='fichevitrine'}</option>
						<option value="1" {if $currentRent == 1}selected="selected"{/if}>{l s="Location" mod='fichevitrine'}</option>
						*}
						{foreach $transacts as $key=>$value}
                            <option value="{$value}" {if $currentTransact == $value} selected="selected"{/if}>
                                {$key}
                            </option>
                        {/foreach}
                        
					</select>
				</td>
				
				<td>
					<label for="f_good">{l s="Type de bien" mod='fichevitrine'}</label>
					<select name="f_good" id="f_good">
						<option value="-1">{l s="Tous" mod='fichevitrine'}</option>
                        {foreach from=$goodTypes key=value item=goodType}
                            <option value="{$goodType->id_prop}" {if $currentGoodType == $goodType->id_prop} selected="selected"{/if}>
                                {$goodType->getName()}
                            </option>
                        {/foreach}
					</select>
				</td>
				<td>
				    <label for="f_theme">{l s="Thème" mod='fichevitrine'} </label>
				    <select name="f_theme">
				        <option value="-1">{l s="Tous" mod='fichevitrine'}</option>
				        {foreach from=$themes key=value item=theme}
				            <option value="{$theme->id_theme}" {if $currentTheme == $theme->id_theme} selected="selected"{/if}>
				                {$theme->getName()}
				            </option>
				        {/foreach}
				    </select>
				</td>
			</tr>
			<tr>
				
				<td></td>
				<td></td>
				<td>
					<label for="f_domain">{l s="Public/Privé" mod='fichevitrine'} </label>
					<select name="f_domain">
					<option value="-1">{l s="Tous" mod='fichevitrine'}</option>
						{foreach $domains as $key=>$value }
							<option value="{$value}" {if $currentDomain == $value} selected="selected" {/if}>
								{$key}
							</option>
						{/foreach}
					</select>
				</td>
				
				<td><input type="submit" value="{l s='Filtrer' mod='fichevitrine'}" name="submitFilter"/></td>
			</tr>
		</table>
	</form>
	<div class="modelList">	
		<table class="fichesList2">
			<tr>
				{foreach $fiches as $key=>$model}

					{if $key % 7 == 0}
					</tr><tr>
					{/if}

					<td>
					
						<div class="">
							<input {if $key == 0}checked="checked"{/if}
									type="radio" 
									name="uniqueModelId" 
									onclick="chooseModel(this.value);" 
									value="{$model->id_fiche}" /> 
							<br/>		
							<label style="width: 80px;">
								{if $model->name == "" }
									{l s='Aucun' mod='fichevitrine'}
								{else}
									{if $model->id_customer == $customer->id}
										<span style="dsplay: inline-block;width: 60px; text-decoration: underline;">
											{if $model->type == 0}
												<a 	href="{$link->getModuleLink('fichevitrine', 'editorfiche',['ficheId'=>$model->id])}" 
													title="{l s='Editer' mod='fichevitrine'}">
													{$model->name}
												</a>
											{else}
												<a 	href="{$link->getModuleLink('fichevitrine', 'editormodel',['ficheId'=>$model->id])}" 
													title="{l s='Editer' mod='fichevitrine'}">
													{$model->name}
												</a>
											{/if}
										</span>
									{else}
										{$model->name}
									{/if}	
								{/if}
							</label>
						</div>
				
						<ul2>
						<li>
						<img src="{$model->getPreview()}" width="100px"/>
						</li>
						</ul2>
						
						<p style="width: 100px;">
							{foreach $themes as $value}
								{if $model->theme == $value->id_theme}
									{$value->getName()} -
								{/if}
							{/foreach}
							{$model->format}
							{foreach $orientations as $key=>$value}
								{if $model->orientation == $value}
									- {$key}
								{/if}
							{/foreach}							
						</p>
						
						{if $model->name != "" }
							{if $model->type == 0 }
								{l s="Fiche" mod='fichevitrine'}
							{else}
								{l s="Modèle" mod='fichevitrine'}
							{/if}
							
							{if $model->public == 0}
								{l s="Public" mod='fichevitrine'}
								
								{if $model->id_customer == $customer->id}
									{l s="Privé" mod='fichevitrine'}
								{else}
									{if $model->groupname_fiche == $groupnamelfv_customer}
										{l s="Groupe" mod='fichevitrine'}
									{else}	
										{l s="Public" mod='fichevitrine'}
									{/if}	
								{/if}	
							{else}
								{l s="Privé" mod='fichevitrine'}
							{/if}	
						{/if}	
					</td>

				{/foreach}
			</tr>
		</table>
	</div>    
    <script type="text/javascript">
		
		function chooseModel(id)
		{
			var element = document.getElementById('modelId');
			element.value = id;
		}
		
		window.onload = function()
		{
			chooseModel( {$fiches[0]->id_fiche} );
		}
	</script>

	{/if}
</div>
